/* *********************************************************************
 R2 module of MPX for Group 3 -2.02
 File Name:   PCB.c
 Author:    Y.Tu  
 Version 2.0 
 Date:  10/01/2008
 Purpose: Provide functions for Internal operations of PCB  for R2 module 

************************************************************************/
#include "pcb.h"


PCB* allo_pcb (void ){

PCB*  p = (PCB*)sys_alloc_mem(sizeof(PCB)); 
return p; 

}


/*Initialize a PCB */ 
PCB* set_pcb(PCB* p,int id, char name[MAX_PCB_NAME], int state, int priority) {

if (p==NULL)
printf("Have not assigned memory yet.");

else
{
p->pcb_id =id;
strcpy(p->pcb_name, name);
p->pcb_state=state;
p->pcb_priority=priority;
p->pcb_memory=NULL;  
p->pcb_resource=NULL; 
p->pcb_context=NULL;
p->pcb_account=NULL;
}

return p; 
}


int free_pcb(PCB* p){
return sys_free_mem( (void*)p );

}

